import bpy

from 节点.全局控制.Node.节点和插座基类 import bl_节点基类

import Core.bl_UI配色 as UI配色
import engine.initLIB.load_dll as engineLib
import ctypes


engineLib.flexCAPI.f_创建XBOX控制器节点.restype = ctypes.c_bool








class C_Node_XBOX控制器(bl_节点基类.C_Node_基类):
	bl_dname = 'bl_node_XBOX控制器'
	bl_label = 'XBOX控制器'

	#m_变量初始化方式 = bpy.props.EnumProperty(items=E_变量初始化方式枚举, update=f_update_变量初始化方式)
	def init(self, context):
		super(C_Node_XBOX控制器, self).f_init(context)
		self.outputs.new('C_Socket_Vec2', name='左摇杆')
		self.outputs.new('C_Socket_Vec2', name='右摇杆')
		self.outputs.new('C_Socket_F32', name='左扳机')
		self.outputs.new('C_Socket_F32', name='右扳机')
		self.outputs.new('C_Socket_I8', name='A')
		self.outputs.new('C_Socket_I8', name='B')
		self.outputs.new('C_Socket_I8', name='X')
		self.outputs.new('C_Socket_I8', name='Y')

		self.outputs.new('C_Socket_I8', name='DPAD_UP')
		self.outputs.new('C_Socket_I8', name='DPAD_DOWN')
		self.outputs.new('C_Socket_I8', name='DPAD_LEFT')
		self.outputs.new('C_Socket_I8', name='DPAD_RIGHT')

		self.outputs.new('C_Socket_I8', name='LEFT_THUMB')
		self.outputs.new('C_Socket_I8', name='RIGHT_THUMB')
		self.outputs.new('C_Socket_I8', name='LEFT_SHOULDER')
		self.outputs.new('C_Socket_I8', name='RIGHT_SHOULDER')
		
		self.f_toCPP(self.id_data)
		
	def draw_buttons(self, context, layout):
		pass
		#layout.prop(self, "m_变量初始化方式", text="初始化方式")
		
	def f_toCPP(self, tree):
		新创建 = engineLib.flexCAPI.f_创建XBOX控制器节点(ctypes.c_wchar_p(tree.name), ctypes.c_wchar_p(self.name), self.f_getPyObject(tree));
		if 新创建 :
			self.use_custom_color = True
			self.color = UI配色.g_输入节点颜色


	
class C_NODE_MENU_XBOX控制器(bpy.types.Operator):
	bl_idname = 'node.global_node_xbox_controller'
	bl_label = 'XBOX控制器'
	bl_options = {'REGISTER', 'UNDO'}
	def execute(operator, context):
		bpy.ops.node.add_node(type='C_Node_XBOX控制器', use_transform=True)
		return {'FINISHED'}
		



















classes = (
	C_Node_XBOX控制器,
	C_NODE_MENU_XBOX控制器,

)

def register():
	for c in classes:
		bpy.utils.register_class(c)
		
def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)





